from django.contrib import admin

# Register your models here.
from django.contrib import admin
from .models import DeviceType, Device, DeviceState, DeviceStateHistory

@admin.register(DeviceType)
class DeviceTypeAdmin(admin.ModelAdmin):
    list_display = ('id', 'name')
    search_fields = ('name',)

@admin.register(Device)
class DeviceAdmin(admin.ModelAdmin):
    list_display = ('id', 'name', 'type', 'family')
    list_filter = ('type',)
    search_fields = ('name',)

@admin.register(DeviceState)
class DeviceStateAdmin(admin.ModelAdmin):
    list_display = ('device', 'updated_at')
    readonly_fields = ('updated_at',)

@admin.register(DeviceStateHistory)
class DeviceStateHistoryAdmin(admin.ModelAdmin):
    list_display = ('device', 'ts', 'command_source')
    list_filter = ('device',)
    readonly_fields = ('ts',)
